package com.ydj.framework.redis;

/**
 * @author rick
 */
public class RedisKey {

    // 幂等
    private static final String IDEMPOTENCE = "idempotence:%s";

    // 自己系统的token, token加不了公司名称，只能知道不同的app
    private static final String TOKEN = "token:%s:%s";

    // 如果发送微信小商店的请求，出现token错误的连续次数。目的是如果token连续错误，就不再做重发
    private static final String TOKEN_ERROR_CONTINUOUS_COUNT = "%s:%s:token_error_continuous_count";

    // 埋点
    private static final String TRACKING = "tracking:%s";

    // 用于手机、邮箱验证码
    private static final String VERIFY_CODE_EMAIL = "verify_code_email:%s";
    private static final String VERIFY_CODE_MOBILE = "verify_code_mobile:%s";

    // 微信公众号的access_token
    private static final String MP_ACCESS_TOKEN = "mp_access_token";

    public static String getCmsToken(String token) {
        return String.format(TOKEN, "cms", token);
    }

    public static String getWebToken(String token) {
        return String.format(TOKEN, "web", token);
    }

    public static String getIdempotence(String hashCode) {
        return String.format(IDEMPOTENCE, hashCode);
    }

    public static String getEmailVerifyCode(String email) {
        return String.format(VERIFY_CODE_EMAIL, email);
    }

    public static String getMobileVerifyCode(String mobile) {
        return String.format(VERIFY_CODE_MOBILE, mobile);
    }

    public static String getMpAccessToken() {
        return MP_ACCESS_TOKEN;
    }
}